# -*- coding: utf-8 -*-
"""
Created on Tue Dec 25 10:09:10 2018

@author: K0180110
"""
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.wait import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
import requests
from bs4 import BeautifulSoup

option = webdriver.ChromeOptions()
option.add_argument('headless')
driver = webdriver.Chrome(chrome_options=option)
# 用于得到每一个概念的html
def get_block_detail(url, header):
    try:
        res_html = requests.get(url, headers=header)
        if res_html.status_code == 200:
            return res_html.text
        return res_html.status_code
    except Exception as err:
        return err

header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'}

www = 'http://q.10jqka.com.cn/gn/detail/code/301558/'
res_html = get_block_detail(www, header)
soup = BeautifulSoup(res_html, 'html.parser')
page_num = int(soup.select('#m-page > span')[0].text.split('/')[-1])

second_url = 'http://q.10jqka.com.cn/gn/detail/field/264648/order/desc/page/2/ajax/1/code/301558'
# driver.get(second_url)
# page_sourcecode = driver.page_source
# driver.close()
second_html = requests.get(second_url)
soup = BeautifulSoup(second_html, 'html.parser')
table_tr = soup.select('body > table > tbody > tr ')
print(table_tr)
td_list = []
for td in table_tr:
    td.select('td > a')
    td_str = td.text.split()
    sss = [td_str[0], td_str[1], td_str[2]]
    td_list.append([td_str[0], td_str[1], td_str[2]])








